package com.gh.filetest;

import org.junit.Test;


import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

public class IoTest {

    /**
     * 通过流读取文件
     */
    @Test
    public void t1(){

        try {
            FileInputStream inputStream = new FileInputStream("C:\\Users\\Administrator\\Pictures\\Camera Roll\\hello.txt");
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            int len = 0;
            byte[] bytes = new byte[1024];
            while ((len = inputStream.read(bytes)) != -1) {

                out.write(bytes,0,len);
            }
            System.out.println(out.toString());
            inputStream.close();
            out.close();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }




}
